package com.kum.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kum.domain.entity.SysUser;
import com.kum.mapper.SysUserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @version V1.0
 * @Package com.kum.service
 * @auhter 枯木Kum
 * @date 2021/6/16-10:24 AM
 * <p>...</p>
 */

@Service
public class SysUserService {

    @Resource
    private SysUserMapper userMapper;


    public SysUser login(SysUser user) {
        QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
        wrapper.eq("username", user.getUsername());
        wrapper.eq("password", user.getPassword());
        SysUser sysUser = userMapper.selectOne(wrapper);

        return sysUser;

    }

    public void save(SysUser user) {
        if (user.getId() != null) {
            userMapper.updateById(user);
        } else {
            userMapper.insert(user);
        }

    }


}
